#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <qqthostaddressmanager.h>
#include <qqtfindservermanager.h>
#include <qqtuseronlinemanager.h>

MainWindow::MainWindow ( QWidget* parent ) :
    QMainWindow ( parent ),
    ui ( new Ui::MainWindow )
{
    ui->setupUi ( this );

    QQtBeServerManager* mm = new QQtBeServerManager ( this );

    QQtHostAddressManager manager;
    QString ip = manager.getHostAddress();
    int port = 4412;

    mm->setTellClient ( ip, port );
    mm->setListeningPort ( 5522 );

    QQtUserOnlineServerManager* m0 = new QQtUserOnlineServerManager ( this );
    connect ( m0, SIGNAL ( signalUserInformationChanged ( QQtDictionary ) ),
              this, SLOT ( slotUserInformationChanged ( QQtDictionary ) ) );
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::slotUserInformationChanged ( const QQtDictionary& dictUser )
{
    QByteArray bytes = dictUser.toJson ( QJsonDocument::Indented );
    ui->textBrowser->clear();
    ui->textBrowser->append ( bytes );
}
